﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_UPDMS_CFG_SETTING_MGT_Select_Paging')
	BEGIN
		DROP Procedure usp_UPDMS_CFG_SETTING_MGT_Select_Paging
	END
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
/******************************************************************************
**	Name : usp_UPDMS_CFG_SETTING_MGT_Select_Paging
**	Desc : 설정관리를 조회한다.
**	Test Exec Query : Exec usp_UPDMS_CFG_SETTING_MGT_Select_Paging 0, 20,'','',''
**	Called by : Cfg_Dac_UPDMS_CFG_SETTING_MGT.cs
**	Program ID : Cfg1011m
**	Auth : 송시명
**	Date : 2013-05-13
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:		Description:
**	--------	--------	---------------------------------------
**	
*******************************************************************************/
CREATE PROC [dbo].[usp_UPDMS_CFG_SETTING_MGT_Select_Paging]
@li_st_page int,
@li_ed_page int,
@ls_setting_nm nvarchar(200),
@ls_setting_cd nvarchar(20),
@ls_setting_value nvarchar(200)
AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON

SELECT a.Seq,
       a.Setting_Nm,
       a.Setting_Cd,
       a.Setting_Value,
       a.Remark,
	   a.Remark_Replace,
       a.Use_Yn
  FROM (
       SELECT ROW_NUMBER() OVER(ORDER BY Setting_Cd ASC) AS Rnum,
              Seq,
              Setting_Nm,
              Setting_Cd,
              Setting_Value,
              Remark,
              REPLACE(Remark, '[X]', Setting_Value) AS Remark_Replace,
              Use_Yn
         FROM UPDMS_CFG_SETTING_MGT
        WHERE Setting_Nm LIKE '%' + @ls_setting_nm + '%'
          AND Setting_Cd LIKE '%' + @ls_setting_cd + '%'
          AND Setting_Value LIKE '%' + @ls_setting_value + '%'
       ) a
 WHERE a.Rnum > @li_st_page AND a.Rnum <= @li_ed_page

GO